Minecraft server Rkit ubuntu upstart [closed]

Posted by user1637491 on Server Fault See other posts from Server Fault or by user1637491
Published on 2012-09-19T20:29:32Z Indexed on 2012/10/04 9:40 UTC
Read the original article Hit count: 453

Filed under:
|
|
|

I have an Intel server running Ubuntu Server 12.04.1 I am working on moving my CraftBukkit Minecraft Server to the new platform. I read the upstart ubuntu cookbook and wrote a .conf file I have a minecraft user (named minecraft) and its home Directory is /home/minecraft it contains

prwxrwxrwx 1 minecraft minecraft    0 Sep 19 14:49 command-fifo
drwx------ 8 minecraft minecraft 4096 Sep 19 14:50 HDsaves
drwx------ 2 minecraft minecraft 4096 Aug 31 15:13 logrolls
-rw-r--r-- 1 root      root         5 Sep 19 14:49 minecraft.pid
drwxrwxrwx 8 minecraft minecraft  180 Sep 19 14:49 ramdisk
-rw------- 1 minecraft minecraft  119 Sep 19 10:34 save.sh
drwxrwxrwx 9 minecraft minecraft 4096 Sep 19 14:50 server
-rw-rw-r-- 1 minecraft minecraft   44 Aug 31 11:40 shutdown.sh

the server directory contains

drwxrwxrwx 6 minecraft minecraft   4096 Aug 30 13:32 Backups
-rwxrwxrwx 1 minecraft minecraft      0 Sep 18 12:26 banned-ips.txt
-rwxrwxrwx 1 minecraft minecraft     17 Sep 18 12:26 banned-players.txt
drwxrwxrwx 4 minecraft minecraft   4096 Aug 30 12:26 buildcraft
-rwxrwxrwx 1 minecraft minecraft   1447 Sep 18 12:26 bukkit.yml
-rwxrwxrwx 1 minecraft minecraft      0 Aug 30 11:05 command-fifo
drwxrwxrwx 2 minecraft minecraft   4096 Aug 30 12:26 config
lrwxrwxrwx 1 minecraft minecraft     23 Sep 19 14:49 craftbukkit.jar -> ramdisk/craftbukkit.jar
-rwxrwxrwx 1 minecraft minecraft  17419 Sep 18 12:26 ForgeModLoader-0.log
-rwxrwxrwx 1 minecraft minecraft  17420 Sep 18 12:24 ForgeModLoader-1.log
-rwxrwxrwx 1 minecraft minecraft  17420 Sep 18 11:53 ForgeModLoader-2.log
-rwxrwxrwx 1 minecraft minecraft   2576 Aug 30 11:05 help.yml
drwxrwxrwx 2 minecraft minecraft   4096 Aug 30 12:31 lib
drwxrwxrwx 3 minecraft minecraft   4096 Sep 19 14:49 logrolls
-rwxrwxrwx 1 minecraft minecraft 200035 Sep  4 17:58 Minecraft_RKit.jar
lrwxrwxrwx 1 minecraft minecraft     12 Sep 19 14:49 mods -> ramdisk/mods
-rwxrwxrwx 1 minecraft minecraft      5 Sep 18 12:26 ops.txt
-rwxrwxrwx 1 minecraft minecraft      0 Aug 30 11:05 permissions.yml
lrwxrwxrwx 1 minecraft minecraft     15 Sep 19 14:49 plugins -> ramdisk/plugins
lrwxrwxrwx 1 minecraft minecraft     16 Sep 19 14:49 redpower -> ramdisk/redpower
-rw-r--r-- 1 root      root         255 Sep 19 15:10 server.log
-rwxrwxrwx 1 minecraft minecraft    464 Sep  8 11:09 server.properties
drwxrwxrwx 3 minecraft minecraft   4096 Sep  5 16:05 SpaceModule
drwxrwxrwx 3 minecraft minecraft   4096 Aug 30 13:07 toolkit
-rwxrwxrwx 1 minecraft minecraft   1433 Sep 14 21:04 wepif.yml
-rwxrwxrwx 1 minecraft minecraft      0 Sep 18 12:26 white-list.txt
lrwxrwxrwx 1 minecraft minecraft     13 Sep 19 14:49 world -> ramdisk/world
lrwxrwxrwx 1 minecraft minecraft     20 Sep 19 14:49 world_nether -> ramdisk/world_nether
lrwxrwxrwx 1 minecraft minecraft     21 Sep 19 14:49 world_the_end -> ramdisk/world_the_end

the startup .conf file:

# Starts the minecraft server after loading JRE from ramdisk
#
# for now im still working on it

description "minecraft-server"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]
oom score -999
kill timeout 60


pre-start script
sh /usr/lib/jvm/java.sh
end script

script
cd /home/minecraft
echo "$(date) Starting minecraft"
sudo cp -r /home/minecraft/HDsaves/* ramdisk
sudo chown -R minecraft:minecraft ramdisk
sudo chmod -R 777 ramdisk
sudo ln -sf ramdisk/* server
sudo chown -R minecraft:minecraft server
sudo chmod -R 777 server
sudo mv server/server.log server/logrolls/
zip server/logrolls/temp.zip server/logrolls/server.log
sudo mv server/logrolls/temp.zip server/logrolls/"$(date)".log.zip
sudo rm server/logrolls/server.log
sudo rm -f command-fifo
sudo mkfifo command-fifo
sudo chown minecraft:minecraft command-fifo
sudo chmod 777 command-fifo
echo "$(date) Root commands finished"
echo "$(date) Starting Wrapper"
cd server
sudo -u minecraft java -Xmx30M -Xms30M -XX:MaxPermSize=40M -Djava.awt.headless=true -jar Minecraft_RKit.jar timv:*spoilers* <> /home/minecraft/command-fifo &
sudo echo $! >| /home/minecraft/minecraft.pid
echo "$(date) Minecraft Started"
end script

pre-stop script
cd /home/minecraft
PID=`cat minecraft.pid`
if [ "$PID" != "" ]; then
echo "Stopping MineCraft Server PID=$PID"
sudo echo save-all >> command-fifo
sudo echo .stopwrapper >> command-fifo
wait $PID
sudo rm minecraft.pid
sudo rsync -rt --delete ramdisk/* HDsaves/
echo "$(date) ramdisk save complete"
echo "MineCraft save-shutdown complete."
else
echo "MineCraft not running"
fi
end script

so when I start it up the upstart gererated log says:

Wed Sep 19 14:49:30 CDT 2012 Starting minecraft
adding: server/logrolls/server.log (stored 0%)
Wed Sep 19 14:49:56 CDT 2012 Root commands finished
Wed Sep 19 14:49:56 CDT 2012 Starting Wrapper
Wed Sep 19 14:49:56 CDT 2012 Minecraft Started

© Server Fault or respective owner

Related posts about java

Related posts about ubuntu-12.04